using System.Collections.Generic;

namespace M13.Game.World
{
    public interface IChunkReference
    {
        void ClearChunkData();
    }

    public static class ChunkReferencePool
    {
        private static Queue<IChunkReference> _pool = new Queue<IChunkReference>();

        public static void Recycle(IChunkReference chunk)
        {
            chunk.ClearChunkData();
            _pool.Enqueue(chunk);
        }

        public static IChunkReference Reuse()
        {
            if (_pool.Count != 0)
                return _pool.Dequeue();
            else return null;
        }

        public static int GetPoolIrCount()
        {
            return _pool.Count;
        }
    }
}